package com.example.demo2.service;

import com.example.demo2.bean.UserBean;
import com.example.demo2.dao.UserBeanDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserBeanService {

    @Autowired
    UserBeanDao dao;

    public List<UserBean> list(){
        List<UserBean> all = dao.findAll();
        return all;
    }

    public UserBean login(UserBean yourBean) {
        UserBean yourBean1 = dao.findOne(Example.of(yourBean)).orElse(null);
        return yourBean1;
    }

    public UserBean register(UserBean yourBean) {
        UserBean save = dao.save(yourBean);
        return save;
    }

    public UserBean findone(UserBean yourBean) {
        UserBean yourBean1 = dao.findOne(Example.of(yourBean)).orElse(null);
        return yourBean1;
    }

    public void deleteById(Integer id) {
        dao.deleteById(id);
    }

    public UserBean update(UserBean yourBean) {
        UserBean save = dao.save(yourBean);
        return save;
    }

    public UserBean addone(UserBean yourBean) {
        UserBean save = dao.save(yourBean);
        return save;
    }
}
